//由公式易知，上界为5*k
public class Solution793 {
    public int preimageSizeFZF(int k) {
        long l=0,r=Math.max((long)k*5,Integer.MAX_VALUE),ans=-1;
        while (l<=r){
            long mid=l+(r-l)/2;
            int total=0;
            long mul=5;
            while (mid>=mul){
                total+= mid /mul;
                mul*=5;
            }
            if (total<k){
                l=mid+1;
            }else if (total>k){
                r=mid-1;
            }else{
                ans=mid;
                l=mid+1;
            }
        }
        if (ans==-1){
            return 0;
        }
        l=0;
        r=Math.max((long)k*5,Integer.MAX_VALUE);
        long ans2=-1;
        while (l<=r){
            long mid=l+(r-l)/2;
            int total=0;
            long mul=5;
            while (mid>=mul){
                total+= mid /mul;
                mul*=5;
            }
            if (total<k){
                l=mid+1;
            }else if (total>k){
                r=mid-1;
            }else{
                ans2=mid;
                r=mid-1;
            }
        }
        return (int)(ans-ans2+1);
    }

    public static void main(String[] args) {
        System.out.println(new Solution793().preimageSizeFZF(0));
    }
}
